
ces = fread('https://dataverse.harvard.edu/api/access/datafile/4949558')

ces = ces[!is.na(vvweight_post) & !is.na(ownhome)]
ces[, ownhome := fifelse(ownhome == 1, 1, 0)]

ces = svydesign(ids = ~caseid, weights = ~vvweight_post, dat = ces) %>%
  svyby(~ownhome, ~inputstate, ., svymean, na.rm = T)

ces = open_dataset('final_long/cycle=2020') %>%
  filter(in_l2 == 1) %>%
  group_by(state = state_file) %>%
  summarise(implied_own_rate = mean(in_cl)) %>%
  collect() %>%
  mutate(state = toupper(state)) %>%
  inner_join(distinct(tigris::fips_codes[,1:2]), by = 'state') %>%
  mutate(state_code = as.integer(state_code)) %>%
  inner_join(ces, by = c('state_code' = 'inputstate'))

save(ces, file = 'summary_data/figA1.rda')
